home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* File subsystem -- Send a file *)
- (* *)
- (* Copyright 1988, 1989, 1991 by H. Roy Engehausen. All rights reserved. *)
- (* This software may be freely distributed and used, but it may not *)
- (* under any circumstances be sold by anyone other than the author. *)
- (* It may be distributed by a commercial company as long as it is *)
- (* for no cost. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBFSSF;
-
- INTERFACE
-
- USES
- bbdummy;
-
- PROCEDURE send_file(file_to_send : file_name_str;
- send_to_conv_task : BOOLEAN);
-
- IMPLEMENTATION
-
- USES
- DOS,
- bbconvm,
- bbfu,
- bbsdata,
- bbsema2,
- bbstr;
-
- (*===========================================================================*)
- (* Send a message file to the user *)
- (*===========================================================================*)
-
- PROCEDURE send_file(file_to_send : file_name_str;
- send_to_conv_task : BOOLEAN);
-
- VAR
- cr_str : STRING[1];
- i : INTEGER;
- text_buffer : STRING[254];
-
- BEGIN;
-
- cr_str := cr;
-
- text_buffer := open_text_file(file_to_send, TRUE);
-
- IF text_buffer <> '' THEN
- BEGIN;
- send_tnc_data_str(cr + text_buffer + cr);
- active_tcb^.error_sw := TRUE;
- EXIT;
- END;
-
- WITH active_tcb^.io_fe^ DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Read from file sending as we go *)
- (*-------------------------------------------------------------------*)
-
- REPEAT
-
- READ(fe_text, text_buffer);
-
- IF EOLN(fe_text) THEN
- BEGIN;
- READLN(fe_text);
-
- send_tnc_data_str(text_buffer + cr);
-
- IF send_to_conv_task THEN
- BEGIN;
- add_c_string(active_tcb^.conv_tcb, @text_buffer, 1);
- add_c_string(active_tcb^.conv_tcb, @cr_str, 1);
- END;
-
- END
- ELSE
- BEGIN;
-
- send_tnc_data_str(text_buffer);
-
- IF send_to_conv_task THEN
- add_c_string(active_tcb^.conv_tcb, @text_buffer, 1);
-
- END;
-
- UNTIL EOF(fe_text); (*----- Read loop -------------------------------*)
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* Close things up *)
- (*-------------------------------------------------------------------*)
-
- text_buffer := close_text_file;
-
- IF text_buffer <> '' THEN
- BEGIN;
- send_tnc_data_str(cr + text_buffer + cr);
- active_tcb^.error_sw := TRUE;
- END;
-
- END;
-
- END.